<?php
  function VoteAlert_pntables(){
    //Initialise table array
    $pntable = array();
    ////////////////////////////////////////////
    //table user
    ////////////////////////////////////////////
    
    //Table province
    $pntable['votealert_province'] = DBUtil::getLimitedTablename('votealert_province');
    $pntable['votealert_province_column'] = array(
                                                'id' => 'province_id',
                                                'name' => 'province_name',
                                                'code' => 'province_code'
                                                );
    $pntable['votealert_province_column_def'] = array(
                                          'id' => 'INT(11)  NOTNULL AUTOINCREMENT PRIMARY',
                                          'name' => 'VARCHAR(255)  DEFAULT NULL',
                                          'code' => 'VARCHAR(255)  DEFAULT NULL'
    );                                      
    
    $pntable['votealert_province_primary_key_column'] = 'id';
                                          
    ObjectUtil::addStandardFieldsToTableDefinition ($pntable['votealert_province_column'], 'province_');
    ObjectUtil::addStandardFieldsToTableDataDefinition($pntable['votealert_province_column_def']);
    //end Table province
    
    
    //Table district
    $pntable['votealert_district'] = DBUtil::getLimitedTablename('votealert_district');
    $pntable['votealert_district_column'] = array(
                                                'id' => 'district_id',
                                                'name' => 'district_name',
                                                'province_id' => 'district_province_id',
                                                'code' => 'district_code'
                                                );
                                                
    $pntable['votealert_district_column_def'] = array(
                                                    'id' => 'int(11) NOT NULL AUTOINCREMENT PRIMARY',
                                                    'name' => 'varchar(255) DEFAULT NULL',
                                                    'province_id' => 'int(11) NOT NULL',
                                                    'code' => 'varchar(255) DEFAULT NULL'
                                                    );
                                                    
    $pntable['votealert_district_primary_key_column'] = 'id';
    ObjectUtil::addStandardFieldsToTableDefinition ($pntable['votealert_district_column'], 'district_');
    ObjectUtil::addStandardFieldsToTableDataDefinition($pntable['votealert_district_column_def']);
    //end Table district
    
    //Table tambon
    $pntable['votealert_tambon'] = DBUtil::getLimitedTablename('votealert_tambon');
    $pntable['votealert_tambon_column'] = array(
                                                'id' => 'tambon_id',
                                                'name' => 'tambon_name',
                                                'district_id' => 'tambon_district_id',
                                                'province_id' => 'tambon_province_id',
                                                'code' => 'tambon_code'
                                                );
                                                
    $pntable['votealert_tambon_column_def'] = array(
                                                    'id' => 'int(11) NOT NULL AUTOINCREMENT PRIMARY',
                                                    'name' => 'varchar(255) DEFAULT NULL',
                                                    'district_id' => 'int(11) NOT NULL',
                                                    'province_id' => 'int(11) NOT NULL',
                                                    'code' => 'varchar(255) DEFAULT NULL'
                                                    );
    $pntable['votealert_tambon_primary_key_column'] = 'id';
    ObjectUtil::addStandardFieldsToTableDefinition ($pntable['votealert_tambon_column'], 'tambon_');
    ObjectUtil::addStandardFieldsToTableDataDefinition($pntable['votealert_tambon_column_def']);
    //end Table tambon
    
    //Table votetype
    $pntable['votealert_votetype'] = DBUtil::getLimitedTablename('votealert_votetype');
    $pntable['votealert_votetype_column'] = array(
                                                'id' => 'votetype_id',
                                                'name' => 'votetype_name',
                                                'group' => 'votetype_group'
                                                );
                                                
    $pntable['votealert_votetype_column_def'] = array(
                                                      'id' => 'int(11) NOT NULL AUTOINCREMENT PRIMARY',
                                                      'name' => 'varchar(255) DEFAULT NULL',
                                                      'group' => 'int(1) NULL'
                                                      );
    $pntable['votealert_votetype_primary_key_column'] = 'id';
    ObjectUtil::addStandardFieldsToTableDefinition ($pntable['votealert_votetype_column'], 'votetype_');
    ObjectUtil::addStandardFieldsToTableDataDefinition($pntable['votealert_votetype_column_def']);
    //end Table votetype
    
    //Table votedata
    $pntable['votealert_votedata'] = DBUtil::getLimitedTablename('votealert_votedata');
    $pntable['votealert_votedata_column'] = array(
                                                  'id' => 'votedata_id',
                                                  'title' => 'votedata_title',
                                                  'province_id' => 'votedata_province_id',
                                                  'district_id' => 'votedata_district_id',
                                                  'tambon_id' => 'votedata_tambon_id',
                                                  'date' => 'votedata_date',
                                                  'lat' => 'votedata_lat',
                                                  'lon' => 'votedata_lon',
                                                  'votetype_id' => 'votedata_votetype_id',
                                                  'president' => 'votedata_president',
                                                  'amount_member' => 'votedata_amount_member',
                                                  'comment' => 'votedata_comment'
                                                  );
     $pntable['votealert_votedata_column_def'] = array(
                                                       'id' => 'int(11) NOT NULL AUTOINCREMENT PRIMARY',
                                                       'title' => 'varchar(255) DEFAULT NULL',
                                                       'province_id' => 'int(11) NOT NULL',
                                                       'district_id' => 'int(11) NOT NULL',
                                                       'tambon_id' => 'int(11) NOT NULL',
                                                       'date' => 'date NOT NULL',
                                                       'lat' => 'double NOT NULL',
                                                       'lon' => 'double NOT NULL',
                                                       'votetype_id' => 'int(11) NOT NULL',
                                                       'president' => 'int(11) NOT NULL',
                                                       'amount_member' => 'int(11) NOT NULL',
                                                       'comment' => 'TEXT DEFAULT NULL'
                                                       	);
    $pntable['votealert_votedata_primary_key_column'] = 'id';
    ObjectUtil::addStandardFieldsToTableDefinition ($pntable['votealert_votedata_column'], 'votedata_');
    ObjectUtil::addStandardFieldsToTableDataDefinition($pntable['votealert_votedata_column_def']);
    //$pntable['votealert_votedata_column_idx'] = array(
    //                                                  'idx_tam_pro_id' => 'pro_id',
    //                                                  'idx_tam_dis_id' => 'dis_id'
    //                                                  );

    //end Table votedata
    
   return $pntable;
  }
?>